﻿Fingerbrisk.docResponse = {

    type: {

        viewless: 1,
        viewfull: 2
    },

    /* called in case of non-pageloadrequest if success in callback */
    onSuccess: function (params) {

        if (!params)
            params = {};

        var request = Fingerbrisk.docRequest.requests[params.luid];

        if (request) {

            //Fingerbrisk.docRequest.requests[params.luid] = null;

            var response = new Fingerbrisk.docResponse.Response(params);
            Fingerbrisk.docRequest.onSuccess.call(null, response, request);
        }
    }
};

Fingerbrisk.docResponse.Response = function (params) {

    if (!params)
        params = {};

    if (typeof params.document == "undefined")
        params.document = {};
    if (typeof params.document.view == "undefined") {
        params.document.view = {};
        this.type = Fingerbrisk.docResponse.type.viewless;
    }
    else
        this.type = Fingerbrisk.docResponse.type.viewfull;
    if (typeof params.document.view.scripts == "undefined")
        params.document.view.scripts = [];
    if (typeof params.document.view.css == "undefined")
        params.document.view.css = [];
    if (typeof params.document.view.html == "undefined")
        params.document.view.html = "";
    if (typeof params.document.dependentDocuments == "undefined")
        params.document.dependentDocuments = [];

    this.document = params.document;
};